package com.smarthealthring.mm.utils;

import android.app.Activity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.smarthealthring.mm.R;
import com.smarthealthring.mm.widgets.CheckStatusTextView;


/**
 * Created by hewei26 on 2017/6/13.
 */

public class ComToolBar {

    public static Toolbar getToolBar(Activity activity) {
        return activity.findViewById(R.id.com_toolbar);
    }

    public static ImageView setleftImg(Activity activity, int drawableId) {
        ImageView ivLeft = (ImageView) activity.findViewById(R.id.iv_left);
        ivLeft.setVisibility(View.VISIBLE);
        ivLeft.setImageResource(drawableId);
        return ivLeft;
    }

    public static TextView setLeftText(Activity activity, String text) {
        TextView tvLeft = (TextView) activity.findViewById(R.id.tv_left);
        tvLeft.setVisibility(View.VISIBLE);
        tvLeft.setText(text);
        return tvLeft;
    }

    public static ImageView setRightImg(Activity activity, int drawableId) {
        ImageView ivRight = (ImageView) activity.findViewById(R.id.iv_right);
        ivRight.setVisibility(View.VISIBLE);
        ivRight.setImageResource(drawableId);
        return ivRight;
    }

    public static CheckStatusTextView setRightText(Activity activity, String text) {
        CheckStatusTextView tvRight = (CheckStatusTextView) activity.findViewById(R.id.tv_right);
        tvRight.setVisibility(View.VISIBLE);
        tvRight.setText(text);
        return tvRight;
    }

    public static TextView setTitle(Activity activity, String title) {
        TextView tvTitle = (TextView) activity.findViewById(R.id.tv_title);
        tvTitle.setText(title);
        return tvTitle;
    }

    public static void changeToolbarBg(Activity activity, int color){
        Toolbar toolbar = (Toolbar) activity.findViewById(R.id.com_toolbar);
        toolbar.setBackgroundColor(color);
    }
}
